package gui;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableRowSorter;

import util.ItemMarketOrderModel;
import util.SystemMarketOrderModel;
import util.Constants.EVEData;
import data.EVEItem;
import data.ItemSystemCollection;

public class ItemList extends JList<EVEItem> {

  private ItemSystemCollection      _collection;
  private DefaultListModel<EVEItem> _listModel;

  public ItemList(ItemSystemCollection collection) {
    _collection = collection;
    DefaultListModel<EVEItem> itemListModel = new DefaultListModel<EVEItem>();
    setModel(itemListModel);
    _listModel = itemListModel;
    setFocusable(false);
  }

  public void addItem(EVEItem item) {
    _listModel.addElement(item);
  }

  public EVEItem getSelectedItem() {
    if (getSelectedIndex() == -1) {
      return null;
    }
    else {
      return _listModel.elementAt(getSelectedIndex());
    }
  }

  public ItemSystemCollection getCollection() {
    return _collection;
  }

  @Override
  public DefaultListModel<EVEItem> getModel() {
    return _listModel;
  }
}
